package com.rt.schedule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rt.schedule.dto.ExamRptDto;
import com.rt.schedule.entity.ExamRpt;
import com.rt.schedule.mapper.ExamRptMapper;
import com.rt.schedule.service.IExamRptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * TODO(实现类示例).
 *
 * <p>TODO(实现类示例).
 *
 * <p>版权所有:Copyright (c) 2019<br/>
 * <a href="http://www.wiseimage.cn/">广州易联众睿图信息技术有限公司</a>.
 *
 * @author 周昭名
 * @version V1.0
 * @since 2019/6/17 1:28
 */
@Service
public class ExamRptServiceImpl implements IExamRptService {

    @Autowired
    ExamRptMapper examRptMapper;

    public int deleteByPrimaryKey(String key) {
        return 0;
    }

    public int deleteByPrimaryKeys(String examNo,String reportNo) {
        QueryWrapper<ExamRpt> qw = new QueryWrapper<ExamRpt>();
        qw.eq(ExamRpt.EXAM_NO,examNo);
        qw.eq(ExamRpt.REPORT_NO,reportNo);
        return examRptMapper.delete(qw);
    }

    public int insertSelective(ExamRpt examRpt) {
        return examRptMapper.insert(examRpt);
    }

    public ExamRpt selectByPrimaryKey(String key) {
        return null;
    }

    public ExamRpt selectByPrimaryKeys(String examNo,String reportNo) {
        QueryWrapper<ExamRpt> qw = new QueryWrapper<ExamRpt>();
        qw.eq(ExamRpt.EXAM_NO,examNo);
        qw.eq(ExamRpt.REPORT_NO,reportNo);
        return examRptMapper.selectOne(qw);
    }

    public int updateByPrimaryKeySelective(ExamRpt examRpt) {

        return examRptMapper.updateById(examRpt);
    }

    public List<ExamRpt> getList(ExamRptDto dto) {
        //构造wrapper查询
        QueryWrapper qw = new QueryWrapper();
        //构造=查询条件
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(ExamRpt.EXAM_NO, dto.getExamNo());
        map.put(ExamRpt.REPORT_NO, dto.getReportName());
        map.put(ExamRpt.IS_ABNORMAL, dto.getIsAbnormal());
        map.put(ExamRpt.REPORT_NAME,dto.getReportName());
        map.put(ExamRpt.REPORT_STATUS,dto.getReportStatus());
        qw.allEq(map, false);
        return examRptMapper.selectList(qw);
    }

    public List<ExamRpt> getListAll() {
        return examRptMapper.selectList(null);
    }
}
